<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="pageable" uri="/WEB-INF/tld/pageable.tld" %>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ include file="/taglibs.jsp"%>
<script type="text/javascript" charset="UTF-8" src="<%=ServerValue.getMidContextPath()%>/js/jquery.tablesorter.js"></script>
<script language="javascript"><!--
	$().ready(function(){
		$("#pcTable").tablesorter({
			sortlist:[[1,0]]
			<c-rt:if test="${not empty productCategories}">
				,headers:{0:{sorter:false},1:{sorter:'inputnumeric'},2:{sorter:false},3:{sorter:false},4:{sorter:false},5:{sorter:false}}
			</c-rt:if>
			<c-rt:if test="${not empty viewShelfProducts}">
				,headers:{0:{sorter:false},1:{sorter:'inputnumeric'},2:{sorter:false},3:{sorter:false},4:{sorter:false},5:{sorter:false},6:{sorter:false}}
			</c-rt:if>
		});
		$("#cbAll").click(function(){
			$(":input[id*=cb_]").attr('checked',$("#cbAll").attr('checked'));
		});		
		$("#searchbtn").click(function(){
			if ( $("#categoryIdParam").val() == "" ){
				alert("請輸入类别编号");
				return false;
			}else{
				$('#productSearchForm').attr('action', 'search.do');
				$("#productSearchForm").submit();

			}
		});
		$(":input[name='sort']").click(function(){
			padZero();
			//$("#pcTable").trigger("update");
			//var sorting = [[1,0]]; 
			//$("#pcTable").trigger("sorton",[sorting]); 
			//location.href="#";
			$('#productSearchForm').attr('action', 'saveShowWeight.do');
			$('#productSearchForm').submit();
			return false;
		});
		$("#sortAsc").click(function(){
			padZero();
			$("#pcTable").trigger("update");
			var sorting = [[1,0]]; 
			$("#pcTable").trigger("sorton",[sorting]); 
			return false;			
		});
		
		$(":input[name='del']").click(function(){
			if ( $(":checkbox[name='delProductCategoryIds']:checked").size() > 0 ){
				$("#productSearchForm").attr("action","del.do");
				$("#productSearchForm").submit();
			}else{
				alert("请选择要删除的商品编号");
				return false;
			}
		});
		$(":input[name='upd']").click(function(){
			$("#productSearchForm").attr("action","edit.do");
			$("#productSearchForm").submit();
		});		
	});
	function padZero(){
		$(":input[name='showSeqs']").each(function(){
			if ( $(this).val() == "" ){
				$(this).val(0);
			}
		});
	}
--></script>
<h1>分类管理排序设定 -查询</h1>
<s:actionerror />
<s:actionmessage />
<s:fielderror />
<br/>
	<s:form action="search.do" method="post" id="productSearchForm">
<div class="data-form">

		<b>类别编号：</b>
		<input name="categoryIdParam" id="categoryIdParam" type="text" title="类别编号" size="10" value="${categoryIdParam}"  onkeyup="value=value.replace(/[^\d]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
	 	<b>关键字：</b><input type="text" name="keyword" value="${param.keyword }"/>
	 <br/>
	  <b>销售状态：</b>
	  <s:checkboxlist list="attributeMenu.options" name="productAttributeParam" listValue="value.name"></s:checkboxlist>
		<s:checkbox name="checkPrice"/>与售价关联
		<input type="button" id="searchbtn" value="查询"/>	

</div>
<span class="txt-rd">主分类不可删除，若变更商品顺序必须先[保存排序编号]，此时前台商品顺序并不会改变，必须再点击[发布顺序]才完成修改</span>
<br/>

<input type="checkbox" id="cbAll" />全選<br/>
共： ${tp.totalRecords} 笔
<table id="pcTable" class="tb-1" width="100%" >
	<s:if test="not checkPrice">
	<thead>
		<tr>
			<th>删除</th>
			<th>排序编号</th>
			<th>显示顺序</th>
			<th>商品图</th>
			<th>商品编号</th>
			<th>商品名称</th>
		</tr>
	</thead>
	<tbody>
		<c-rt:choose>
			<c-rt:when test="${not empty result}">
				<c-rt:forEach items="${result}" var="productCategory" varStatus="index">
					<tr>
						<td>
							<c-rt:choose>
								<c-rt:when test="${productCategory['MAIN_CATEGORY_ID'] ne categoryIdParam}">
									<input type="checkbox" id="cb_${index.count}" name="delProductCategoryIds" value="${productCategory['PRODCUT_CATEGORY_ID']}"/>
								</c-rt:when>
								<c-rt:otherwise>主分类</c-rt:otherwise>
							</c-rt:choose>
							<input type="hidden" name="productIds" value="${productCategory['PRODUCT_ID']}"/>
						</td>
						<td>
							<input type="text" id="showSeqs_${index.count}" name="showSeqs" value="${!empty productCategory['SORT_WEIGHT']?productCategory['SORT_WEIGHT']:400 }" maxlength="5" size="5"/>
						</td>
						<td>${productCategory},${productCategory['SORT_ORDER']}</td>						
						<td><img onError="this.src='/PImg/blank_75.gif'" src="/PImg/${fn:substring(productCategory['PRODUCT_ID'],0,4)}/${productCategory['PRODUCT_ID']}/${productCategory['PRODUCT_ID']}_m75.jpg"/></td>
						<td>${productCategory['PRODUCT_ID']}</td>
						<td>${productCategory['PRODUCT_NAME']}</td>
					</tr>
				</c-rt:forEach>
			</c-rt:when>
			<c-rt:otherwise>
				<tr>
					<td colspan="6">查无商品资料</td>
				</tr>
			</c-rt:otherwise>
		</c-rt:choose>
		</tbody>
				
		<c-rt:if test="${not empty result}">
			<tr>
				<td><input type="button" name="del" value="删除"/></td>
				<td><input type="button" name="sort" value="保存排序编号"/></td>					
				<td colspan="4"><input type="button" name="upd" value="发布顺序" style="text-align: left;"/></td>
			</tr>	
		</c-rt:if>	
	</s:if>
	<s:else>
	<thead>
		<tr>
			<th>删除</th>
			<th>排序编号</th>
			<th>显示顺序</th>
			<th>商品图</th>
			<th>商品编号</th>
			<th>商品名称</th>
			<th>售价</th>
		</tr>
	</thead>
	<tbody>
		<c-rt:choose>
			<c-rt:when test="${not empty result}">
				<c-rt:forEach items="${result}" var="productCategory" varStatus="index">
					<tr>
						<td>
							<c-rt:choose>
								<c-rt:when test="${productCategory['MAIN_CATEGORY_ID'] ne categoryIdParam}">
									<input type="checkbox" id="cb_${index.count}" name="delProductCategoryIds" value="${productCategory['PRODCUT_CATEGORY_ID']}"/>
								</c-rt:when>
								<c-rt:otherwise>主分类</c-rt:otherwise>
							</c-rt:choose>
							<input type="hidden" name="productCategoryIds" value="${productCategory['PRODCUT_CATEGORY_ID']}"/>
						</td>
						<td><input type="text" id="showSeqs_${index.count}" name="showSeqs" value="${!empty productCategory['SORT_WEIGHT']?productCategory['SORT_WEIGHT']:400 }" maxlength="5" size="5"/></td>
						<td>${productCategory['SORT_ORDER']}</td>
						<td><img onError="this.src='/PImg/blank_75.gif'" src="/PImg/${fn:substring(productCategory['PRODUCT_ID'],0,4)}/${productCategory['PRODUCT_ID']}/${productCategory['PRODUCT_ID']}_m75.jpg"/></td>
						<td>${productCategory['PRODUCT_ID']}</td>
						<td>${productCategory['PRODUCT_NAME']}</td>
						<td><fmt-rt:formatNumber value="${productCategory['SHELF_PRICE']}" pattern="#####0.0"/></td>
					</tr>
				</c-rt:forEach>
			</c-rt:when>
			<c-rt:otherwise>
				<tr>
					<td colspan="7">查无商品资料</td>
				</tr>
			</c-rt:otherwise>
		</c-rt:choose>
		</tbody>
		
		<c-rt:if test="${not empty result}">
			<tr>
				<td><input type="button" name="del" value="删除"/></td>
				<td><input type="button" name="sort" value="保存排序编号"/></td>					
				<td colspan="5"><input type="button" name="upd" value="发布顺序"  style="text-align: left;"/></td>
			</tr>
		</c-rt:if>
	</s:else>
</table>
</s:form>
<table width="100%">
<tr>
			<td colspan="7">
			<pageable:Pageable url="/ecadmin/productCategory/search.do" formname="pcForm" key="pc"></pageable:Pageable>

			</td>
		</tr>	
</table>